package com.zt.bigdata.flink.batch

import com.typesafe.scalalogging.LazyLogging
import org.apache.flink.api.scala._


object WordCount extends LazyLogging {
  def main(args: Array[String]) {
    val env = ExecutionEnvironment.getExecutionEnvironment
    val text: DataSet[String] = env.fromElements(
      "Who's there?",
      "I think I hear them. Stand, ho! Who's there?")

    logger.info("AAAAAAAAAAA")
    logger.error("BBBBBBBBBB")
    val word = text.flatMap {
      x =>
        x.toLowerCase.split("\\W+") filter (_.nonEmpty)
    }
    val pair = word
      .map(x => (x, 1))

    val groupBy = pair.groupBy(0)

    val count = groupBy.sum(1)

    count.print()
  }
}
